import React,{Component} from 'react';
import './shop.css'
const Shop=(props)=>{
  console.log(props);
 
  return(
    <div>
      <h2>购物车</h2>
      <table className="t">
        <tbody >
        <tr >
          <th className="table">序号</th>
          <th className="table">名称</th>
          <th className="table">价钱</th>
          <th className="table">数量</th>
          <th className="table">操作</th>
        </tr>
      {
       props.arr.map((item,i)=>
       <tr key={i}>
         <td className="table">{item.id}</td>
         <td className="table">{item.name}</td>
         <td className="table">{item.price}</td>
         <td className="table">{item.count}</td>
         <td className="table">
           {item.count===0?
             <button onClick={()=>props.cart(i)} className="button">添加购物车</button>:
             <div>
               <button  onClick={()=>props.add(i)} className="jia">+</button>
               <button  onClick={()=>props.jian(i)} className="jia">-</button>
             </div>
           }
         </td>
       </tr>
        )

      }
        </tbody>
      </table>
    </div>
  )
}
export default Shop